/**
 *    Copyright (C) 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_CORE_BLOB_MAP_PAGES_DATA_PAGE_HPP
#define	_CUBEFS_CORE_BLOB_MAP_PAGES_DATA_PAGE_HPP

#include <cubefs/core/tools/reflection.hpp>
#include <cubefs/core/container/container.hpp>

namespace cubefs    {
namespace blob_map  {

using namespace cubefs::tools;
using namespace cubefs::ctr;

#pragma pack(1)

template <Int Size>
class DynVectorData
{
    Short size_;
    Byte value_[Size - sizeof(Size)];

public:
    DynVectorData() {}

    static Int max_size() {
        return Size;
    }

    Int reindex() {}

    const Short &size() const {
        return size_;
    }

    Short &size() {
        return size_;
    }

    const Byte& value(Int idx) const {
        return value_[idx];
    }

    Byte& value(Int idx) {
        return value_[idx];
    }

    Int byte_size() const {
        return size_ + sizeof(size_);
    }

    void shift(BigInt pos, BigInt length) {
        
    }

    MetadataList GetFields(Long &abi_ptr) const
    {
        MetadataList list;
        FieldFactory<Short>::create(list, size_,  "SIZE", abi_ptr);
        FieldFactory<Byte>::create(list, value_[0], "VALUE", Size, abi_ptr);
        return list;
    }
};

#pragma pack()

}}

#endif